var app = Common.initApp(['ngAnimate','angularFileUpload']);
Common.initDirective(app);
 File.init(app);
 Pageoffice.direcPageoffice(app);
app.controller('openOfficeController', [
    '$scope', '$http', '$templateCache', 'FileUploader',
    function ($scope, $http, FileUploader,$templateCache) {

        $scope.checkPageOfficeInsert = function () {
            var flag = Pageoffice.checkPageOffice();
            if (flag) {
                $("#pageoffice-download-link").hide();
            } else {
                $("#pageoffice-download-link").show();
            }
        };

        $scope.openOnLineEditPage = function () {
            var dataUrl = Common.webRoot() + "/szboanda/hbdc/gwgl/fwgl/controller/customizationFileProcessController/file/info";
            var openDocumentConfig = {
                method: "POST",
                url: dataUrl,
                data: JSON.stringify({
                    YWSJID: $scope.YWID,
                    LXDM: $scope.LXDM,
                    ZLXDM: $scope.ZLXDM,
                    NEWFLAG: true,
                    WJMC: wjmc,
                    WJLX: 'docx'
                }),
                success: function (data) {
                    $scope.WJID = data.data.WJID;
                    $scope.YWSJID = data.data.YWSJID;
                    $scope.WJMC = data.data.WJMC;
                    $scope.modeType = "1";
                    $scope.openOffice();
                }
            };
            Common.send($scope, $http, openDocumentConfig);
        }


        $scope.openOffice = function () {
            //debugger;
            Pageoffice.openOffice($scope, $http, {
                templateId: $scope.WJID,
                ywsjId: $scope.YWSJID,
                /*beanName: 'ProjectAdapter',
                beanParams: 'obj001',*/
                fileName: $scope.WJMC,
                title: $scope.WJMC,
                modeType: $scope.modeType,
                userDefineBtns: 'buttons.history',
                showTitlebar: false,
                showSaveBtn: false,
                saveWithRevision: true,
                showAcceptRevisionBtn: true,
                showRevisionBtn: true
            });
        };



        $scope.uploader = {};
        $scope.uploadConfig = {
            uploadId: 'upload', // 组件ID
            LTBH: 'jgjc', // 系统编号
            LXDMS: $scope.LXDM, // 附件类型代码
            ZLXDMS: $scope.ZLXDM, //附件子类型代码
            YWSJID: $scope.YWID,
            multiple: false,
            readOnly: true,
            buttonConfig: {
                hideUploadBtn: true
            }
        }
    }
]);
